package com.som.minigame;

import java.util.Scanner;
import java.lang.Math;
public class PTB2 {
	double a, b, c, x1, x2;
	double delta;
	public void input() {
		Scanner scan = new Scanner(System.in);
		System.out.print("Enter a: ");
		a = scan.nextFloat();
		System.out.print("Enter b: ");
		b = scan.nextFloat();
		System.out.print("Enter c: ");
		c = scan.nextFloat();
	}
	public void result() {
		String result;
		if (a == 0) {
			if (b == 0) {
				if (c == 0) {
					result = "Vo so nghiem";
				} else {
					result = "Vo ngiem";
				}
			} else {
				x1 = (-c)/b;
				result = "Phuong trinh co nghiem duy nhat x = " + x1;
			}
		} else {
			delta = b*b - 4*a*c;
			
			if (delta < 0) {
				result = "Phuong trinh vo nghiem";
			} else if (delta == 0) {
				x1 = -b/(2*a);
				result = "Phuong trinh co nghiem duy nhat x = "+x1;
			} else {
				x1 = (-b+Math.sqrt(delta))/(2*a);
				x2 = (-b-Math.sqrt(delta))/(2*a);
				result = "x1 = "+x1+", x2 = "+x2;
			}
		}
		System.out.println(result);		
	}
			
}
